import mysql from 'mysql2/promise';
import { DB_USER, DB_PASSWORD, DB_HOST, DB_NAME, MESSAGE_NO_SQL} from '@config/config';

const pool = mysql.createPool({
  host: DB_HOST,
  user: DB_USER,
  password: DB_PASSWORD,
  database: DB_NAME,
  waitForConnections: true,
  connectionLimit: 8,
  maxIdle: 2, 
  idleTimeout: 10000, 
  queueLimit: 20, 
  enableKeepAlive: true,
  keepAliveInitialDelay: 0,
});

pool.on('error', (err) => { console.error(MESSAGE_NO_SQL, err); });

export default pool